package com.zhoug.zmui3demo.ui;

import android.os.Bundle;

import com.zhoug.common3.utils.ToastUtils;
import com.zhoug.zmui3.task.TaskFlow;
import com.zhoug.zmui3.task.ZMUITaskFlowView;
import com.zhoug.zmui3demo.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

public class ZMUITaskFlowActivity extends AppCompatActivity {

    private ZMUITaskFlowView mTaskFlowView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_z_m_u_i_task_flow);
        findViews();
        List<TaskFlow> taskFlows = Arrays.asList(
                new TaskFlow("2020-01-01", "发布", "国家管理员", true),
                new TaskFlow("2020-01-01", "审核", "张三", true),
                new TaskFlow("2020-01-01", "派发", "李四", true),
                new TaskFlow("2020-01-01", "检查", null, false),
                new TaskFlow("2020-01-01", "任务结束", null, false),
                new TaskFlow("2020-01-01", "归档", null, false)
        );
        List<TaskFlow> childNodes = new ArrayList<>();
        childNodes.add(new TaskFlow("转交", null, "(1)"));
        childNodes.add(new TaskFlow("限期整改", "李四", null));
        childNodes.add(new TaskFlow("委办", "张三", "(2/3)"));
        childNodes.add(new TaskFlow("处罚", null, "(2)"));
//        childNodes.add(new TaskFlowNode("处罚2", null, "(2)"));
//        childNodes.add(new TaskFlowNode("处罚2", null, "(2)"));
        taskFlows.get(3).setChild(childNodes);
        taskFlows.get(1).setIcon(ContextCompat.getDrawable(this,R.drawable.zmui_search));
        mTaskFlowView.setData(taskFlows);

        mTaskFlowView.setOnNodeClickListener(new ZMUITaskFlowView.OnNodeClickListener() {
            @Override
            public void onNodeClick(TaskFlow taskFlow) {
                ToastUtils.toastShort(taskFlow.getName());
            }

            @Override
            public void onIconClick(TaskFlow taskFlow) {
                ToastUtils.toastShort("点击"+taskFlow.getName()+"的图标");

            }
        });
    }

    private void findViews() {
        mTaskFlowView = findViewById(R.id.taskFlowView);
    }
}